package com.qipay.holiday.config;

import org.apache.commons.lang3.StringUtils;

/**
 * Creator: Yao
 * Date:    2017/12/13
 * For:
 * Other:
 */
public enum HolidayTypeEnum {

    WORK((byte) 0, "否"),
    HOLIDAY((byte) 1, "是");

    private byte type;
    private String name;

    HolidayTypeEnum(byte type, String name) {
        this.type = type;
        this.name = name;
    }

    public byte getType() {
        return type;
    }

    public void setType(byte type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static byte match(String key) {

        if (StringUtils.isBlank(key))
            return HolidayTypeEnum.WORK.getType();

        for (HolidayTypeEnum p : HolidayTypeEnum.values()) {
            if (p.getName().equalsIgnoreCase(key))
                return p.getType();
        }

        return HolidayTypeEnum.WORK.getType();
    }
}
